const db = wx.cloud.database();
const _ = db.command;
const app = getApp();
Page({
  data: {
    userList: [],
    userListCheck: [],
    userType: app.globalData.userInfo.type,
  },
  onCheck: function (event) {
    // console.log(event.target.dataset.id)
    db.collection('Management_user').doc(event.target.dataset.id)
      .update({
        data: {
          userListCheck: true,
        }
      })
    wx.showToast({
      title: '审核通过',
      icon: 'success'
    })
    db.collection('Management_user').where({
      selectAdmin: _.eq(app.globalData.userInfo._id)
    }).get().then(res => {
      if (res.data.length != 0) {
        this.setData({
          userList: res.data
        })
      }
    })
  },
  onLoad: function (options) {
    db.collection('Management_user').where({
      selectAdmin: _.eq(app.globalData.userInfo._id)
    }).get().then(res => {
      if (res.data.length != 0) {
        this.setData({
          userList: res.data
        })
      }
    })
    db.collection('Management_user').where({
      selectAdmin: _.eq(app.globalData.userInfo._id)
    }).get().then(res => {
      if (res.data.length != 0) {
        this.setData({
          userList: res.data
        })
      }
    })
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },
})